package com.dzjcloud.dzj.upms.biz.config;

import com.dzjcloud.dzj.upms.biz.service.GatewayService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;


/**
 * 网关路由加载
 *
 * 实现了ApplicationRunner接口后 就可以在run方法内启动后自动执行
 *
 * @author zxiaozhou
 * @date 2022-07-21 11:22
 * @since JDK1.8
 */
@Component
@Slf4j
@RequiredArgsConstructor
public class RouterInitRunner implements ApplicationRunner {
    private final GatewayService gatewayService;

    @Override
    public void run(ApplicationArguments args) {
        // 加载路由并通知网关刷新
        gatewayService.reloadRouter();
    }
}
